package cn.wolfcode.wms.web.controller;

import cn.wolfcode.wms.domain.Permission;
import cn.wolfcode.wms.qo.QueryObject;
import cn.wolfcode.wms.service.IPermissionService;
import cn.wolfcode.wms.util.JSONResult;
import cn.wolfcode.wms.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("permission")
public class PermissionController {
    @Autowired
    private IPermissionService permissionService;
    @RequestMapping("list")
    public String list(Model model, @ModelAttribute("qo") QueryObject qo){

        PageResult result = permissionService.queryForList(qo);

        model.addAttribute("result",result);
        return "permission/list";
    }

    @ResponseBody
    @RequestMapping("reload")
    public Object roload(){
        permissionService.reload();
        JSONResult json = new JSONResult();
        return json;
    }



    @ResponseBody
    @RequestMapping("delete")
    public Object delete(Long id){

       permissionService.delete(id);
        JSONResult json = new JSONResult();
        return json;
    }
}
